import Taro from '@tarojs/taro'

function showToast({ content, icon, duration }: { content: string, icon: string, duration?: number }) {
  const params = { title: content, icon };
  if (duration) {
    params.duration = duration;
  }
  Taro.showToast(params);
}

function success(content: string) {
  showToast({ content, icon: 'success' });
}
function info(content: string) {
  showToast({ content, icon: 'none' });
}

function error(content: string) {
  showToast({ content, icon: 'none' });
}

function showLoading({ content }: { content: string }) {
  Taro.showLoading({ title: content });
}

function hideLoading() {
  Taro.hideLoading();
}

function loading(content: string) {
  showLoading({ content });
}




export default { success, error, info, showLoading, hideLoading, loading }
